package com.hamizhong.iflowers.web.action.admin.statics;

import net.sf.json.JSONObject;

import com.hamizhong.iflowers.service.IFlowerCountService;
import com.hamizhong.iflowers.utils.MyConstants;
import com.hamizhong.iflowers.web.base.MyBaseAjaxAction;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.FlowerCountVO;
import com.hamizhong.iflowers.web.vo.IObjectVO;

public class AjaxUpdateFlowerCountAction extends MyBaseAjaxAction {
	
	private IFlowerCountService iFlowerCountService = null;
	
	public IFlowerCountService getiFlowerCountService() {
		return iFlowerCountService;
	}
	public void setiFlowerCountService(IFlowerCountService iFlowerCountService) {
		this.iFlowerCountService = iFlowerCountService;
	}
	
	@Override
	protected JSONObject doRequest() {
		logger.info("...invoke...AjaxUpdateFlowerCountAction...");
		String flowerCountName = getRQ().getParameter("flowerCountName");
		String flowerCountId = getRQ().getParameter("flowerCountId");
		String sortId = getRQ().getParameter("sortId");
		String remarks = getRQ().getParameter("remarks");
		IOPResultDto<IObjectVO> resultDto = new IOPResultDto<IObjectVO>();
		FlowerCountVO flowerCountVO = new FlowerCountVO();
		flowerCountVO.setFlowerCountName(flowerCountName);
		flowerCountVO.setFlowerCountId(Integer.valueOf(flowerCountId));
		flowerCountVO.setSortId(Integer.valueOf(sortId));
		flowerCountVO.setRemarks(remarks);
		resultDto = iFlowerCountService.updateFlowerCount(flowerCountVO);
		JSONObject jo = new JSONObject();
		if(resultDto.isSuccess()) {
			jo.put("result", MyConstants.AJAX_SUCCESS);
		}else {
			jo.put("result", MyConstants.AJAX_FAILED_ALERT);
			jo.put("msg", resultDto.getErrorMSG());
		}
		return jo;
	}

}
